Skip to content

fix(firestore): fix empty message reject inside transaction body #9177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

cherylEnkidu
Copy link
Contributor

@cherylEnkidu cherylEnkidu commented Jul 21, 2025

Discussion
This pull request resolves a bug where a Firestore transaction would hang indefinitely if an error without a message property was thrown within the transaction's body.

The root cause of this issue was an incorrect assumption in the SDK that an error object would always contain a message. This change corrects the logic to ensure that the SDK can gracefully handle errors that lack a message.

Fixes #9147

Testing
Verify in integration test

@cherylEnkidu cherylEnkidu requested review from a team as code owners July 21, 2025 18:59
Copy link

changeset-bot bot commented Jul 21, 2025

🦋 Changeset detected

Latest commit: 56ca0e1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@firebase/firestore Patch
firebase Patch
@firebase/firestore-compat Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Jul 21, 2025

Size Report 1

Affected Products

  • @firebase/app-check

    TypeBase (56fbe52)Merge (f206537)Diff
    browser26.3 kB26.4 kB+28 B (+0.1%)
    main27.3 kB27.3 kB+28 B (+0.1%)
    module26.3 kB26.4 kB+28 B (+0.1%)
  • @firebase/firestore

    TypeBase (56fbe52)Merge (f206537)Diff
    browser391 kB391 kB+1 B (+0.0%)
    main611 kB611 kB+1 B (+0.0%)
    module391 kB391 kB+1 B (+0.0%)
    react-native392 kB392 kB+1 B (+0.0%)
  • @firebase/firestore-lite

    TypeBase (56fbe52)Merge (f206537)Diff
    browser115 kB115 kB+1 B (+0.0%)
    main158 kB158 kB+1 B (+0.0%)
    module115 kB115 kB+1 B (+0.0%)
    react-native116 kB116 kB+1 B (+0.0%)
  • @firebase/performance

    TypeBase (56fbe52)Merge (f206537)Diff
    browser31.1 kB31.2 kB+169 B (+0.5%)
    main31.5 kB31.7 kB+169 B (+0.5%)
    module31.1 kB31.2 kB+169 B (+0.5%)
  • bundle

    TypeBase (56fbe52)Merge (f206537)Diff
    app-check (CustomProvider)37.2 kB37.2 kB+10 B (+0.0%)
    app-check (ReCaptchaEnterpriseProvider)39.6 kB39.6 kB+10 B (+0.0%)
    app-check (ReCaptchaV3Provider)39.5 kB39.6 kB+10 B (+0.0%)
    firestore (Transaction)224 kB224 kB+1 B (+0.0%)
    firestore-lite (Transaction)107 kB107 kB+1 B (+0.0%)
    performance (trace)62.0 kB62.1 kB+96 B (+0.2%)
  • firebase

    TypeBase (56fbe52)Merge (f206537)Diff
    firebase-app-check-compat.js22.8 kB22.8 kB+6 B (+0.0%)
    firebase-app-check.js25.0 kB25.0 kB+10 B (+0.0%)
    firebase-compat.js800 kB800 kB+97 B (+0.0%)
    firebase-firestore-compat.js349 kB349 kB+1 B (+0.0%)
    firebase-firestore-lite.js138 kB138 kB+1 B (+0.0%)
    firebase-firestore.js455 kB455 kB+1 B (+0.0%)
    firebase-performance-compat.js40.2 kB40.3 kB+90 B (+0.2%)
    firebase-performance-standalone-compat.js105 kB105 kB+90 B (+0.1%)
    firebase-performance.js45.5 kB45.6 kB+90 B (+0.2%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/NQ4Gc6dR2e.html

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Jul 21, 2025

Size Analysis Report 1

Affected Products

  • @firebase/app-check

    • initializeAppCheck

      Size

      TypeBase (56fbe52)Merge (f206537)Diff
      size11.5 kB11.5 kB+10 B (+0.1%)
      size-with-ext-deps36.2 kB36.2 kB+10 B (+0.0%)
  • @firebase/firestore

    • runTransaction

      Size

      TypeBase (56fbe52)Merge (f206537)Diff
      size139 kB139 kB+1 B (+0.0%)
      size-with-ext-deps211 kB211 kB+1 B (+0.0%)
  • @firebase/performance

    • getPerformance

      Size

      TypeBase (56fbe52)Merge (f206537)Diff
      size19.1 kB19.2 kB+94 B (+0.5%)
      size-with-ext-deps61.8 kB61.9 kB+96 B (+0.2%)
    • initializePerformance

      Size

      TypeBase (56fbe52)Merge (f206537)Diff
      size19.3 kB19.3 kB+94 B (+0.5%)
      size-with-ext-deps55.4 kB55.5 kB+96 B (+0.2%)
    • trace

      Size

      TypeBase (56fbe52)Merge (f206537)Diff
      size19.0 kB19.1 kB+94 B (+0.5%)
      size-with-ext-deps54.8 kB54.9 kB+96 B (+0.2%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/g6FnYERz1I.html

@cherylEnkidu cherylEnkidu requested a review from a team as a code owner July 21, 2025 19:27
@cherylEnkidu cherylEnkidu changed the title Fix empty message reject inside transaction body fix(firestore): fix empty message reject inside transaction body Jul 21, 2025
Copy link
Contributor

github-actions bot commented Jul 21, 2025

Changeset File Check ✅

  • No modified packages are missing from the changeset file.
  • No changeset formatting errors detected.

Copy link
Contributor

@MarkDuckworth MarkDuckworth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise, LGTM

@@ -113,7 +113,7 @@ export class TransactionRunner<T> {
}

private isRetryableTransactionError(error: Error): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can make error an optional param to communicate the behavior we have observed. This also supports the change you made below for future readers.

private isRetryableTransactionError(error?: Error): boolean {...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ultranit: Consider using error: Error | undefined rather than error?: Error.

It's somewhat nonsensical to not specify an argument to a function named "isRetryableTransactionError", and defining the parameter as error?: Error allows nonsensical function invocations like this.

In contrast, specifying the argument as error: Error | undefined will cause a TypeScript build error if no argument is specified to the function, but will still allow calling it with an explicit undefined argument.

IMO the latter is the intended use.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Transactions that experience errors never resolve
4 participants